package longcaisuyun.longcai.com.net;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.suyunbean.CaoZuoBean;

/**
 * Created by Administrator on 2016/4/27.
 */
@HttpInlet(Net.CAOZUO)
public class GetCaoZuo extends WHAsyGet<GetCaoZuo.Info> {
    public GetCaoZuo(AsyCallBack asyCallBack) {
        super(asyCallBack);
    }
    protected Info parser(JSONObject object) {
        Info info = new Info();
        try {
            info.message = object.getString("message");
            if (info.message.equals("1")) {
                for (int j = 0; j < object.getJSONArray("list").length(); j++) {
                    CaoZuoBean caoZuoBean = new CaoZuoBean();
                    caoZuoBean.setTitle(object.getJSONArray("list").getJSONObject(j).getString("title"));
                    caoZuoBean.setId(object.getJSONArray("list").getJSONObject(j).getString("id"));
                    caoZuoBean.setPicurl(object.getJSONArray("list").getJSONObject(j).getString("picurl"));
                    info.list.add(caoZuoBean);
                }
            }
            return info;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static class Info {
        public String message = "";
        public List<CaoZuoBean> list = new ArrayList<CaoZuoBean>();
    }
}
